//
//  DHHomeViewController.m
//  Dresshere
//
//  Created by ZhangPeng on 2017/12/21.
//  Copyright © 2017年 张朋. All rights reserved.
//

#import "DHHomeViewController.h"
#import "DHCategoryAndScenarioViewController.h"
#import "DHLeftViewController.h"
#import "DHCityListViewController.h"
#import "Cover.h"
#import "DHCategoryModel.h"
#import "DHScenarioModel.h"
#import "DHBrandItemView.h"
#import "DHExpressCityHUD.h"
#import "DHAddressViewController.h"
#import "DHLeftMenuView.h"
#import "DHLeftNotLogView.h"
#import "DHSearchViewController.h"
#import "DHShoppingCartViewController.h"
#import "DHNewsDetailController.h"
#import "DHLoginGenderViewController.h"
#import "CartButton.h"
#import "DHSearchView.h"
#import "DHHomeExploreView.h"

@interface DHHomeViewController ()<UIScrollViewDelegate>

@property (weak, nonatomic) IBOutlet NSLayoutConstraint *cityWidthLayout;
@property (weak, nonatomic) IBOutlet UIButton *cityButton;
@property (weak, nonatomic) IBOutlet UIButton *menuButton;
@property (strong, nonatomic) CartButton *cartButton;
@property (weak, nonatomic) IBOutlet UIButton *searchButton;
@property (weak, nonatomic) IBOutlet DHGradualButton *inquireButton; //查询按钮
@property (weak, nonatomic) IBOutlet UIScrollView *scrollView;
@property (weak, nonatomic) IBOutlet UIView *bottomView;
@property (weak, nonatomic) IBOutlet UIPageControl *pageControl;
@property (weak, nonatomic) IBOutlet UIButton *expressCityButton;
@property (weak, nonatomic) IBOutlet UIButton *memberStateButton;
@property (weak, nonatomic) IBOutlet UIButton *addressButton;
@property (strong, nonatomic) DHLeftMenuView *leftMenuview;
@property (strong, nonatomic) DHLeftNotLogView *leftNoLogMenuView;
@property (strong, nonatomic) UIView *leftMenuBGView;
@property (weak, nonatomic) IBOutlet UIView *navView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *navViewTopLayout;

@property (strong, nonatomic) DHExpressCityHUD *hud;

@property (strong, nonatomic) NSArray *coversArray;

@property (weak, nonatomic) IBOutlet UILabel *categoryLabel;
@property (strong, nonatomic) DHCategoryModel *selectedCategoryModel;
@property (weak, nonatomic) IBOutlet UILabel *sceneLabel;
@property (strong, nonatomic) DHScenarioModel *selectedSceneModel;

// 改版首页新增布局
@property (weak, nonatomic) IBOutlet UIScrollView *contentScrollView;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *homeViewWidthLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *homeLeftLayout;
@property (strong, nonatomic) DHSearchView *searchView;
@property (strong, nonatomic) DHHomeExploreView *exploreView;
@property (weak, nonatomic) IBOutlet UIButton *homeButton;
@property (weak, nonatomic) IBOutlet UIButton *costumeButton;
@property (weak, nonatomic) IBOutlet UIButton *exploreButton;
@property (weak, nonatomic) IBOutlet UIButton *businessButton;
@property (weak, nonatomic) IBOutlet UIButton *feastButton;
@property (weak, nonatomic) IBOutlet UIButton *everydayButton;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentScrollViewBottomLayout;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *homeBottomViewBottomLayout;

@property (assign, nonatomic) BOOL isInitSubViews;

@end

@implementation DHHomeViewController

- (void)viewDidLayoutSubviews{
    [super viewDidLayoutSubviews];
    [self.contentScrollView setContentSize:CGSizeMake(kScreenWidth * 3, self.contentScrollView.height)];
    if (!self.isInitSubViews) {
        [self.contentScrollView setContentSize:CGSizeMake(kScreenWidth * 3, self.contentScrollView.height)];
        
        self.homeViewWidthLayout.constant = kScreenWidth;
        
        if (iPhoneX) {
            self.searchView = [[DHSearchView alloc] initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, self.contentScrollView.height + 35)];
        }else{
            self.searchView = [[DHSearchView alloc] initWithFrame:CGRectMake(kScreenWidth, 0, kScreenWidth, self.contentScrollView.height)];
        }
        [self.searchView loadConditionData];
        [self.contentScrollView addSubview:self.searchView];
        
        self.exploreView = [DHHomeExploreView shareDHHomeExploreView];
        if (iPhoneX) {
            self.exploreView.frame = CGRectMake(kScreenWidth * 2, 0, kScreenWidth, self.contentScrollView.height + 35);
        }else{
            self.exploreView.frame = CGRectMake(kScreenWidth * 2, 0, kScreenWidth, self.contentScrollView.height);
        }
        [self.exploreView initView];
        [self.contentScrollView addSubview:self.exploreView];
        self.isInitSubViews = YES;
    }
}

- (NSArray *)brandArray{
    if (!_coversArray) {
        _coversArray = [NSArray array];
    }
    return _coversArray;
}

- (DHExpressCityHUD *)hud{
    if (!_hud) {
        _hud = [DHExpressCityHUD shareDHExpressCityHUD];
    }
    return _hud;
}

- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = YES;
    
    if (iPhoneX) {
        self.homeBottomViewBottomLayout.constant = 27;
    }
    
//    [self cityConfig];
    [self cagegoryAndSceneConfig];
    [self loadUserVip];
    [self loadCartNumber];
    
    [self.leftMenuview layoutSubviews];
    
    // 刷新通知数量
    [[GlobalManager shareGlobalManager] refreshNotificationsUnreadCountAndBlock:^(id data, NSError *error) {
        [self.leftMenuview updateNotificationsUnreadCount];
    }];
}

- (void)viewDidAppear:(BOOL)animated{
    [super viewDidAppear:animated];
    self.navigationController.navigationBarHidden = YES;
    
    // 用户未登录，且未选别性别的情况下
    if (![Login isLogin]) {
        if (![[NSUserDefaults standardUserDefaults] objectForKey:USER_SELECT_SEX]) {
            DHLoginGenderViewController *genderController = [[DHLoginGenderViewController alloc] init];
            [self presentViewController:genderController animated:YES completion:nil];
        }
    }
}

- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden = NO;
}

- (void)viewDidDisappear:(BOOL)animated{
    [super viewDidDisappear:animated];
    self.navigationController.navigationBarHidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    if ([UIDevice systemVersion] < 11) {
        self.navViewTopLayout.constant = 20;
    }
    if (iPhoneX) {
        self.contentScrollViewBottomLayout.constant += 34;
    }
    self.automaticallyAdjustsScrollViewInsets = NO;
    
    [self initView];
    [self buttonActions];
    [self loadCoversData];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(gaodeaddressselected:) name:@"home_gaodeaddressselected" object:nil];
    addNObserver(@selector(refresh_cart), @"refresh_cart");
    addNObserver(@selector(city_list_selected:), @"city_list_selected");
}

- (void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"home_gaodeaddressselected" object:nil];
    removeNObserver(@"refresh_cart");
}

- (void)city_list_selected:(NSNotification *)not{
    dispatch_async(dispatch_get_main_queue(), ^{
        [self.cityButton setTitle:[not.object objectForKey:@"city"] forState:UIControlStateNormal];
    });
}

- (void)refresh_cart{
    [self.cartButton.numberButton setTitle:[NSString stringWithFormat:@"%ld",[GlobalManager shareGlobalManager].cartNumber] forState:UIControlStateNormal];
}

- (void)gaodeaddressselected:(NSNotification *)not{
    if (not){
        NSDictionary *dic = not.object;
        GeoCode *geoCode = [dic objectForKey:@"geoCode"];
        [self.addressButton setTitle:[NSString stringWithFormat:@"%@%@",geoCode.district,geoCode.address] forState:UIControlStateNormal];
        [[NSUserDefaults standardUserDefaults] setObject:[NSDictionary entityToDictionary:geoCode] forKey:USER_HOME_ADDRESS];
        [[NSUserDefaults standardUserDefaults] synchronize];
    }
}

- (void)initView{
    self.bottomView.layer.cornerRadius = 2;
    self.bottomView.clipsToBounds = YES;
    
    if ([[NSUserDefaults standardUserDefaults] objectForKey:USER_HOME_ADDRESS]) {
        GeoCode *geoCode = [GeoCode modelWithDictionary:[[NSUserDefaults standardUserDefaults] objectForKey:USER_HOME_ADDRESS]];
        [self.addressButton setTitle:[NSString stringWithFormat:@"%@%@",geoCode.district,geoCode.address] forState:UIControlStateNormal];
    }
    
//    self.cityButton.titleLabel.adjustsFontSizeToFitWidth = YES;
    
    self.cartButton = [[CartButton alloc] initWithFrame:CGRectMake(kScreenWidth - 48, 0, 43, 44)];
    [self.navView addSubview:self.cartButton];
    
    WeakSelf(weakSelf)
    
    [self.cartButton bk_addEventHandler:^(id sender) {
        if ([Login isLogin]) {
            DHShoppingCartViewController *cartController = [[DHShoppingCartViewController alloc] init];
            [weakSelf.navigationController pushViewController:cartController animated:YES];
        }else{
            [kAppDelegate configLoginController];
        }
    } forControlEvents:UIControlEventTouchUpInside];
    
    [[AddressManager shareAddressManager] updateCurrentLocationAndBlock:^(id data, NSError *error) {
        [self cityConfig];
    }];
}

- (void)buttonActions{
    WeakSelf(weakSelf)
    [self.menuButton bk_addEventHandler:^(id sender) {
        if ([Login isLogin]) {
            [weakSelf showLeftMenuView];
        }else{
            [weakSelf showLeftNoLogMenuView];
        }
    } forControlEvents:UIControlEventTouchUpInside];
    
    [self.cityButton bk_addEventHandler:^(id sender) {
        DHCityListViewController *cityListVC = [[DHCityListViewController alloc] init];
        [weakSelf presentViewController:cityListVC animated:YES completion:nil];
    } forControlEvents:UIControlEventTouchUpInside];
    
    [self.expressCityButton bk_addEventHandler:^(id sender) {
//        if (!self.hud.isHUDShow) {
            self.hud.isHUDShow = YES;
            self.hud.cityLabel.text = self.cityButton.titleLabel.text;
            
            NSString *cityString = self.cityButton.titleLabel.text;
            if ([[GlobalManager shareGlobalManager].supportCitiesArray containsObject:cityString]) {
                self.hud.desLabel.text = @"已开通同城6小时送达服务";
            }else{
                self.hud.desLabel.text = @"时尚出行更精彩";
            }
            
            [kKeyWindow addSubview:self.hud];
//        }
    } forControlEvents:UIControlEventTouchUpInside];
    
    [self.addressButton bk_addEventHandler:^(id sender) {
        DHAddressViewController *addressController = [[DHAddressViewController alloc] init];
        addressController.isHomePush = YES;
        [weakSelf.navigationController pushViewController:addressController animated:YES];
    } forControlEvents:UIControlEventTouchUpInside];
    
    [self.searchButton bk_addEventHandler:^(id sender) {
        DHSearchViewController *searchController = [[DHSearchViewController alloc] init];
        [weakSelf.navigationController pushViewController:searchController animated:YES];
    } forControlEvents:UIControlEventTouchUpInside];
    
    [self.inquireButton bk_addEventHandler:^(id sender) {
        DHSearchViewController *searchController = [[DHSearchViewController alloc] init];
        [weakSelf.navigationController pushViewController:searchController animated:YES];
    } forControlEvents:UIControlEventTouchUpInside];
    
    // 首页改版新增
    [self.homeButton bk_addEventHandler:^(id sender) {
        [weakSelf.contentScrollView setContentOffset:CGPointMake(0, 0)];
        [weakSelf.homeButton setTitleColor:[UIColor colorWithHexString:@"#AE9231"] forState:UIControlStateNormal];
        [weakSelf.costumeButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
        [weakSelf.exploreButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
    } forControlEvents:UIControlEventTouchUpInside];
    [self.costumeButton bk_addEventHandler:^(id sender) {
        [weakSelf.contentScrollView setContentOffset:CGPointMake(kScreenWidth, 0)];
        [weakSelf.homeButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
        [weakSelf.costumeButton setTitleColor:[UIColor colorWithHexString:@"#AE9231"] forState:UIControlStateNormal];
        [weakSelf.exploreButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
        [weakSelf.searchView loadConditionData];
    } forControlEvents:UIControlEventTouchUpInside];
    [self.exploreButton bk_addEventHandler:^(id sender) {
        [weakSelf.contentScrollView setContentOffset:CGPointMake(kScreenWidth * 2, 0)];
        [weakSelf.homeButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
        [weakSelf.costumeButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
        [weakSelf.exploreButton setTitleColor:[UIColor colorWithHexString:@"#AE9231"] forState:UIControlStateNormal];
    } forControlEvents:UIControlEventTouchUpInside];
    
    [self.businessButton bk_addEventHandler:^(id sender) {
        [weakSelf.businessButton setTitleColor:[UIColor colorWithHexString:@"#AE9231"] forState:UIControlStateNormal];
        [weakSelf.feastButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
        [weakSelf.everydayButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
    } forControlEvents:UIControlEventTouchUpInside];
    [self.feastButton bk_addEventHandler:^(id sender) {
        [weakSelf.businessButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
        [weakSelf.feastButton setTitleColor:[UIColor colorWithHexString:@"#AE9231"] forState:UIControlStateNormal];
        [weakSelf.everydayButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
    } forControlEvents:UIControlEventTouchUpInside];
    [self.everydayButton bk_addEventHandler:^(id sender) {
        [weakSelf.businessButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
        [weakSelf.feastButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
        [weakSelf.everydayButton setTitleColor:[UIColor colorWithHexString:@"#AE9231"] forState:UIControlStateNormal];
    } forControlEvents:UIControlEventTouchUpInside];
}

- (void)showLeftMenuView{
    if (!self.leftMenuBGView) {
        self.leftMenuBGView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
        self.leftMenuBGView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.0];
        [self.view addSubview:self.leftMenuBGView];
    }
    if (!self.leftMenuview) {
        self.leftMenuview = [DHLeftMenuView shareDHLeftMenuView];
        [self.leftMenuBGView addSubview:self.leftMenuview];
        
        UIButton *hideButton = [[UIButton alloc] initWithFrame:CGRectMake(kScreenWidth/3 * 2, 0, kScreenWidth/3, kScreenHeight)];
        [hideButton setBackgroundColor:[UIColor clearColor]];
        [self.leftMenuBGView addSubview:hideButton];
        WeakSelf(weakSelf)
        [hideButton bk_addEventHandler:^(id sender) {
            [weakSelf hideLeftMenuView];
        } forControlEvents:UIControlEventTouchUpInside];
    }
    
    self.leftMenuBGView.hidden = NO;
    [self.leftMenuview layoutSubviews];
    [UIView animateWithDuration:0.3 animations:^{
        self.leftMenuview.left = 0;
        self.leftMenuBGView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
    }];
}

- (void)showLeftNoLogMenuView{
    if (!self.leftMenuBGView) {
        self.leftMenuBGView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight)];
        self.leftMenuBGView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.0];
        [self.view addSubview:self.leftMenuBGView];
    }
    if (!self.leftNoLogMenuView) {
        self.leftNoLogMenuView = [DHLeftNotLogView shareDHLeftNotLogView];
        [self.leftMenuBGView addSubview:self.leftNoLogMenuView];
        
        UIButton *hideButton = [[UIButton alloc] initWithFrame:CGRectMake(kScreenWidth/3 * 2, 0, kScreenWidth/3, kScreenHeight)];
        [hideButton setBackgroundColor:[UIColor clearColor]];
        [self.leftMenuBGView addSubview:hideButton];
        WeakSelf(weakSelf)
        [hideButton bk_addEventHandler:^(id sender) {
            [weakSelf hideLeftMenuView];
        } forControlEvents:UIControlEventTouchUpInside];
    }
    
    self.leftMenuBGView.hidden = NO;
    [UIView animateWithDuration:0.3 animations:^{
        self.leftNoLogMenuView.left = 0;
        self.leftMenuBGView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
    }];
}

- (void)hideLeftMenuView{
    [UIView animateWithDuration:0.3 animations:^{
        self.leftMenuview.left = -kScreenWidth/3 * 2;
        self.leftNoLogMenuView.left = -kScreenWidth/3 * 2;
        self.leftMenuBGView.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.0];
    } completion:^(BOOL finished) {
        self.leftMenuBGView.hidden = YES;
    }];
}

//获取cover数据
- (void)loadCoversData{
    __weak typeof(self) weakSelf = self;
    [[DHNetAPIClient shareDHNetAPIClient] request_coversAndBlock:^(id data, NSError *error) {
        weakSelf.coversArray = [CoverList modelWithDictionary:data].covers;
        weakSelf.pageControl.numberOfPages = weakSelf.coversArray.count;
        [weakSelf showCovers];
    }];
}

// 获取当前购物车数量
- (void)loadCartNumber{
    if ([Login isLogin]) {
        [[DHNetAPIClient shareDHNetAPIClient] request_cart_countAndBlock:^(id data, NSError *error) {
            [self.cartButton.numberButton setTitle:[NSString stringWithFormat:@"%ld",[[data objectForKey:@"count"] integerValue]] forState:UIControlStateNormal];
        }];
    }
}

// 获取vip信息
- (void)loadUserVip{
    if ([Login isLogin]) {
        [[DHNetAPIClient shareDHNetAPIClient] request_user_vipAndBlock:^(id data, NSError *error) {
            Vip *vip = [Vip modelWithDictionary:data];
            if (vip.vip) {
                self.memberStateButton.hidden = NO;
//                [self.memberStateButton setTitle:[NSString stringWithFormat:@" %@",vip.info.level.name] forState:UIControlStateNormal];
            }else{
                self.memberStateButton.hidden = YES;
            }
        }];
    }
}

//品类
- (IBAction)categoryAction:(id)sender {
    if ([Login isLogin]) {
        DHCategoryAndScenarioViewController *categoryController = [[DHCategoryAndScenarioViewController alloc] initWithInterestSetting:HomeInterestSettingCategory];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:categoryController];
        [self presentViewController:navController animated:YES completion:^{
            
        }];
    }else{
        [kAppDelegate configLoginController];
    }
}
//场景
- (IBAction)scenarioAction:(id)sender {
    if ([Login isLogin]) {
        DHCategoryAndScenarioViewController *scenarioController = [[DHCategoryAndScenarioViewController alloc] initWithInterestSetting:HomeInterestSettingScenario];
        UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:scenarioController];
        [self presentViewController:navController animated:YES completion:^{
            
        }];
    }else{
        [kAppDelegate configLoginController];
    }
}

- (void)showCovers{
    [self.scrollView removeAllSubviews];
    [self.coversArray enumerateObjectsUsingBlock:^(Cover *cover, NSUInteger idx, BOOL * _Nonnull stop) {
        DHBrandItemView *itemView = [DHBrandItemView shareDHBrandItemView];
        itemView.frame = CGRectMake(idx * self.scrollView.width, 0, self.scrollView.width, self.scrollView.height);
        [itemView updateBrand:cover andArticleID:cover.article];
        [itemView bk_addEventHandler:^(DHBrandItemView *sender) {
            DHNewsDetailController *adController = [[DHNewsDetailController alloc] initWithArticleID:sender.articleID];
            [self.navigationController pushViewController:adController animated:YES];
        } forControlEvents:UIControlEventTouchUpInside];
        [self.scrollView addSubview:itemView];
    }];
    self.scrollView.contentSize = CGSizeMake(self.coversArray.count * self.scrollView.width, 0);
}

- (void)cityConfig{
    NSString *cityString;
    if ([[NSUserDefaults standardUserDefaults] objectForKey:USER_SELECT_CITY]) {
        [self.cityButton setTitle:[[NSUserDefaults standardUserDefaults] objectForKey:USER_SELECT_CITY] forState:UIControlStateNormal];
        cityString = [[NSUserDefaults standardUserDefaults] objectForKey:USER_SELECT_CITY];
    }else{
        cityString = [AddressManager shareAddressManager].city? : @"北京";
        [self.cityButton setTitle:cityString forState:UIControlStateNormal];
    }
    
    if ([[GlobalManager shareGlobalManager].supportCitiesArray containsObject:cityString]) {
        [self.expressCityButton setTitle:[NSString stringWithFormat:@"%@ 已开通同城6小时送达服务", cityString] forState:UIControlStateNormal];
//        if (!self.hud.isHUDShow) {
//            self.hud.isHUDShow = YES;
//            self.hud.cityLabel.text = self.cityButton.titleLabel.text;
//            self.hud.desLabel.text = @"已开通同城6小时送达服务";
//            [kKeyWindow addSubview:self.hud];
//        }
    }else{
        [self.expressCityButton setTitle:[NSString stringWithFormat:@"%@ 时尚出行更精彩", cityString] forState:UIControlStateNormal];
    }
    
    self.cityWidthLayout.constant = [self.cityButton.titleLabel.text widthForFont:self.cityButton.titleLabel.font] + 11;
}

- (void)cagegoryAndSceneConfig{
    if ([UserSelectedManager shareUserSelectedManager].category) {
        self.categoryLabel.text = [UserSelectedManager shareUserSelectedManager].category.title;
    }
    if ([UserSelectedManager shareUserSelectedManager].scenario) {
        self.sceneLabel.text = [UserSelectedManager shareUserSelectedManager].scenario.title;
    }
}

#pragma mark - UIScrollViewDelegate
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView{
    NSInteger pageIndex = scrollView.contentOffset.x / self.scrollView.width;
    self.pageControl.currentPage = pageIndex;
    if (scrollView.tag == 1000) {
        switch (pageIndex) {
            case 0:{
                [self.homeButton setTitleColor:[UIColor colorWithHexString:@"#9E8226"] forState:UIControlStateNormal];
                [self.costumeButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
                [self.exploreButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
                break;
            }
            case 1:{
                [self.homeButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
                [self.costumeButton setTitleColor:[UIColor colorWithHexString:@"#9E8226"] forState:UIControlStateNormal];
                [self.exploreButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
                [self.searchView loadConditionData];
                break;
            }
            case 2:{
                [self.homeButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
                [self.costumeButton setTitleColor:[UIColor colorWithHexString:@"#4A494A"] forState:UIControlStateNormal];
                [self.exploreButton setTitleColor:[UIColor colorWithHexString:@"#9E8226"] forState:UIControlStateNormal];
                break;
            }
            default:
                break;
        }
        
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
